package org.brisling.websocket.service;

import java.util.List;

import org.brisling.base.domain.ListDomain;
import org.brisling.base.domain.RetDomain;
import org.brisling.common.ConstSysParam;
import org.brisling.common.util.StringUtil;
import org.brisling.websocket.domain.WSDomain;
import org.brisling.sysman.service.base.BaseSysmanService;
import org.brisling.websocket.repository.WebsocketMessageRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;


@RestController
@RequestMapping("/app/message")
/**
 * 
 * <p>Title: WebsocketMessageService</p>
 * <p>Description: websocket消息服务类</p>
 * <p>Company: tongking</p>
 * @author jackson wang
 * @since 1.0
 * @version 1.0
 * @date 2017年6月12日 下午11:36:59
 */
public class WebsocketMessageService extends BaseSysmanService<WSDomain>{
	
	@SuppressWarnings("unused")
	@Autowired
	private WebsocketMessageRepo baseRepo;
	
	public WebsocketMessageService(){
		this.moduleName = ConstSysParam.MODULE_WEBSOCKET_MESSAGE;
	}
	
	/**
	 * 获取业务主页面 
	 * @return
	 */
	@RequestMapping("/mainPage.action")
	public ModelAndView getMainPage(){
		return getBizMainPage();
	}
	
	/**
	 * 获取业务编辑页面
	 * @return
	 */
	@RequestMapping("/editPage.action")
	public ModelAndView getEditPage(){
		return getBizEditPage();
	}
	
	
	/**
	 * 删除记录,单条或批量删除记录,id不为空，执行单条删除，id为空且ids不为空，执行批量删除
	 * @param id	待删除的单条记录id
	 * @param ids	待删除的多条记录id，以','分隔
	 * @return
	 */
	@RequestMapping("/del.action")
	public RetDomain delRow(@RequestParam(value="id",required=false) Long id,@RequestParam(value="ids",required=false) String ids){
				
		return super.delRows(id, ids);		 
	}
	
	/**
	 * 删除记录,单条或批量删除记录,id不为空，执行单条删除，id为空且ids不为空，执行批量删除
	 * @param id	待删除的单条记录id
	 * @param ids	待删除的多条记录id，以','分隔
	 * @return
	 */
	@RequestMapping("/flowDel.action")
	public RetDomain delFlowRow(@RequestParam(value="id",required=false) Long id,@RequestParam(value="ids",required=false) String ids){
		
			return delRow(id,ids);
		
	}
	
	
	/**
	 * 保存业务记录
	 * @param id
	 */
	@RequestMapping("/save.action")
	public WSDomain save(@RequestBody String body){
		WSDomain role = bodyToObj(body, WSDomain.class);		
		super.save(role);
		return role;
	}
	
	/**
	 * 发送业务信息
	 * @param id
	 */
	@RequestMapping("/sendMsg.action")
	public WSDomain sendMsg(@RequestBody String body){
		WSDomain role = bodyToObj(body, WSDomain.class);		
		super.save(role);
		return role;
	}
	
	
	
	
}
